package com.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("session")
public class SessionController {

    @RequestMapping("create")
    public String createSession(HttpServletRequest req){

        //如果没有该用户对象的session对象，则新建session对象返回
        //如果有该用户对应的session对象，则直接取出（一个用户只有一个session对象）
        HttpSession session = req.getSession();

        return session.getId();

    }

}
